package vtc;

import java.util.*;

import com.ib.client.Contract;
import com.ib.client.Order;

import com.tictactec.ta.lib.*;

public class DummyIBBrokerUnit extends FunctionalUnit
{	
	private double netLiquidation_;
	private double cash_;
	
	DummyIBBrokerUnit(String id, VtcArrayBlockingQueue inQueues[], VtcArrayBlockingQueue outQueues[], double initialCash)
	{
		super(id, inQueues, outQueues);
		netLiquidation_ = initialCash;
		cash_ = initialCash;
	}
	
	public void functionalProcess() throws InterruptedException
	{
		VtcTimeTaggedEvent event = inValue_;
		Object [] eventv = (Object[])event.getEvent();
		//System.out.print("event type: " + eventv[0].getClass().getName() + "\n");
		Map<String, Object> eventMap = (Map<String, Object>)eventv[0];
		double price = (Double)eventv[1];
		Date timeTag = event.getTimeTag();
		Contract contract = (Contract)eventMap.get("contract");
		Order order = (Order)eventMap.get("order");
		
//		System.out.print("-----------------------------------------------\n");
//		System.out.print("Contract:\n" + contract.toString() + "\n");
//		System.out.print("Order:\n" + order.toString() + "\n");
//		System.out.print("Price:\n" + price + "\n");
//	
		//do something
		
		outValue_ = new VtcTimeTaggedEvent(new Integer(0), timeTag);
	}
}